package com.qfmy.webapp.controller.wallpaper;

import com.qfmy.common.result.Result;
import com.qfmy.webapp.service.wallpaper.WallpaperRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.controller.wallpaper
 * @date 2025/9/14
 * @description 壁纸评分
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/app/wallpaperRating")
public class WallpaperRatingController {
    /**
     * 注入壁纸评分服务
     */
    @Autowired
    private WallpaperRatingService wallpaperRatingService;

    /**
     * 添加评分
     */
    @RequestMapping("/addWallpaperRating")
    public Result addWallpaperRating(@RequestParam Integer id, @RequestParam Double  score){
        wallpaperRatingService.addWallpaperRating(id, score);
        return Result.ok();
    }

    /**
     * 根据壁纸ID判断是否评分过
     */
    @RequestMapping("/isRated")
    public Result<Double> isRated(@RequestParam Integer id){
        return Result.ok(wallpaperRatingService.isRated(id));
    }

}
